import { trans } from '@utils/common';
import { post, get, postL, getL } from '@utils/http';
import { SERVE_URL } from '@utils/config';
const urls = url => {
    return SERVE_URL + 'apiExp' + url;
};
export default {
    //=================渠道管理 Start
    //渠道管理-删除
    async channelConfigDelete(param) {
        const res = await trans(get(urls('/active/channelConfig/delete'), param));
        return res.success;
    },
    //查询所有渠道（只返回渠道名称）
    async channelConfigChanneName(param) {
        const res = await trans(get(urls('/active/channelConfig/queryChannelName'), param));
        return res;
    },
    //渠道管理-新增
    async channelConfigAdd(param) {
        const res = await trans(post(urls('/active/channelConfig/add'), param));
        return res.success;
    },
    //渠道管理-修改
    async channelConfigEdit(param) {
        const res = await trans(post(urls('/active/channelConfig/edit'), param));
        return res.success;
    },
    //渠道管理-分页
    async channelConfigPageQuery(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(urls('/active/channelConfig/pageQuery'), {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    //==================渠道管理 End
    //==================渠道统计 Start
    //渠道统计 分页
    async channelReportPageQuery(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(urls('/active/channelReport/pageQuery'), {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    //渠道统计 导出
    async channelReportExport(param) {
        const res = await trans(postL(urls('/active/channelReport/export'), param, { responseType: 'blob' }));
        return res.data;
    },
    //渠道统计用户明细 导出
    async ChannelUserExport(param) {
        const res = await trans(postL(urls('/active/channelReport/exportChannelUser'), param, { responseType: 'blob' }));
        return res.data;
    },
    //渠道统计 点击用户明细
    async channelReportUserDetail(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(urls('/active/channelReport/userDetail'), {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    //根据当前登录角色查询渠道（只返回渠道名称）
    async queryChannelNameByLoginUser(param) {
        const res = await trans(get(urls('/active/channelReport/queryChannelNameByLoginUser'), param));
        return res;
    },
    //渠道统计-修改外部数据
    async updateOutData(param) {
        const res = await trans(post(urls('/active/channelReport/updateOutData'), param));
        return res.success;
    },
    //==================渠道统计End
};
